package ynu.edu.Util;

import org.springframework.stereotype.Component;

import java.io.*;
import java.util.Properties;

@Component
public class PropertiesUtil {

    private String filePath = "config.properties";


    public Properties loadProperties() {
        Properties properties = new Properties();
        try (FileInputStream input = new FileInputStream(filePath)) {
            properties.load(input);
        } catch (IOException e) {
            System.err.println("无法加载配置文件: " + e.getMessage());
        }
        return properties;
    }

    // 保存属性到文件
    public void saveProperties(Properties properties) {
        try (FileOutputStream output = new FileOutputStream(filePath)) {
            properties.store(output, null);
        } catch (IOException e) {
            System.err.println("无法保存配置文件: " + e.getMessage());
        }
    }
}
